package adapter;

import agricultural.AgriculturalMachine;
import strategy.WorkStrategy;
import strategy.impl.WeedingStrategy;

public class AdvancedWeederAdapter extends AgriculturalMachine {
    private AdvancedWeeder advancedWeeder;

    public AdvancedWeederAdapter(AdvancedWeeder advancedWeeder) {
        super(advancedWeeder.getMachineId());
        this.advancedWeeder = advancedWeeder;
        this.workStrategy = new WeedingStrategy();
    }

    @Override
    public void adjustToEnvironment(double soilMoisture, int cropGrowthStatus, String weatherData) {
        System.out.println(machineId + "收到环境数据更新通知");
        advancedWeeder.adjustToEnvironment(soilMoisture, cropGrowthStatus, weatherData);
        performWork();
    }

    @Override
    public void performWork() {
        advancedWeeder.performSmartWeeding();
    }

    @Override
    public void setWorkStrategy(WorkStrategy workStrategy) {
        // 适配器可以选择性实现此方法
        System.out.println(machineId + "不支持直接设置工作策略，使用内置智能策略");
    }

    @Override
    public void update(double soilMoisture, int cropGrowthStatus, String weatherData) {

    }
}